Skip to content

refactor(stark): make Table.data private, route writes through set_main#698

Merged
MauroToscano merged 1 commit into
mainfrom
refactor/private-table-data
Jun 22, 2026
Merged

refactor(stark): make Table.data private, route writes through set_main#698
MauroToscano merged 1 commit into
mainfrom
refactor/private-table-data

Conversation

@MauroToscano

Copy link
Copy Markdown
Contributor

What

Table.data was a pub field. That let callers bypass the get/set/get_row accessors and index the row-major buffer directly — which is why several different trace-write styles had crept in.

This narrows Table.data to pub(crate) and routes the stragglers through the API:

  • keccak_rc::update_multiplicitiestrace.main_table.data[base + cols::MU] = mutrace.set_main(round, cols::MU, mu)
  • test reads (branch_bus_tests, keccak_rnd_tests, trace_builder_tests) → get_main(row, col)

bitwise and decode already used set_main/get/get_row — unchanged.

Why it's more than cleanup

The direct .data write was a latent bug: under the disk-spill feature, Table can be backed by an mmap, and get/set handle that case while raw .data indexing does not. keccak_rc's poke would touch the wrong memory on a spilled table. Privatizing the field makes the bypass impossible to reintroduce.

Correctness

Behavior-preserving. cargo test -p lambda-vm-prover --lib: 416 passed (the 5 *ecsm* failures are pre-existing/environmental, identical on main). cargo test -p stark --lib: 128 passed. cargo fmt + cargo clippy clean. The byte-pinned keccak_rc/bitwise static-commitment tests pass, confirming the set_main path produces identical traces.

Relationship to #693

Supersedes #693part 2 of 2 (part 1 is the dword_wl/dword_hl limb-decomposition PR). Independent of part 1; can land in either order.

…set_main

Table.data was a pub field, letting callers bypass the get/set accessors and
poke the row-major buffer directly. That bypass is also a latent bug: under the
disk-spill feature Table can be mmap-backed, and get/set handle that case while
raw .data indexing does not -- keccak_rc's `main_table.data[..] = mu` would be
wrong on a spilled table.

Narrow Table.data to pub(crate) and route the one production write
(keccak_rc multiplicity) through set_main, plus the handful of test reads
through get_main. bitwise/decode already used the get/set API.

Behavior-preserving: prover lib tests 416 pass (the 5 ecsm failures are
pre-existing/environmental, identical on main), stark 128 pass; fmt + clippy
clean.

Supersedes #693 (2/2).
@MauroToscano MauroToscano added this pull request to the merge queue Jun 22, 2026
Merged via the queue into main with commit 1c77707 Jun 22, 2026
12 checks passed
@MauroToscano MauroToscano deleted the refactor/private-table-data branch June 22, 2026 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants